package com.kasinf.sample.kafka.controller;

import com.kasinf.sample.kafka.message.TestMessages;
import com.kasinf.sample.kafka.producer.MessageProducer;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author : Kaiser
 * @Date: 2025/5/23  14:25
 */
@RestController
@RequestMapping("/message")
public class MessageController {

    @Resource
    private MessageProducer messageProducer;

    @PostMapping("/publish")
    public String publish(String message) {
        TestMessages testMessages = new TestMessages(123465L, 1111L, message);
        messageProducer.push(testMessages);
        return "ok";
    }

    @PostMapping("/produce")
    public String produce(String message) {
        TestMessages testMessages = new TestMessages(123465L, 1111L, message);
        messageProducer.send(testMessages);
        return "ok";
    }
}
